import 'dart:io';

import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:window_manager/window_manager.dart';

import 'package:ddlmanager/pages/home.dart';
import 'package:ddlmanager/backend/app_state.dart';

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await AppState().init();

  if (Platform.isWindows || Platform.isMacOS) {
    await windowManager.ensureInitialized();
    WindowOptions windowOptions = const WindowOptions(
      size: Size(700, 500),
      minimumSize: Size(100, 100),
      center: true,
      // backgroundColor: Colors.transparent,
      // titleBarStyle: TitleBarStyle.hidden,
    );
    windowManager.waitUntilReadyToShow(windowOptions, () async {
      await windowManager.show();
      await windowManager.focus();
    });
  }

  runApp(
    ChangeNotifierProvider(create: (context) => AppState(), child: HomePage()),
  );
}
